package edu.tongji.jiaowu.service.impl;

import java.util.List;
import com.tongji.quickCRUDQ.service.impl.BaseManagerImpl;
import edu.tongji.jiaowu.dao.EvtStudentDao;
import edu.tongji.jiaowu.dao.EvtStudentResultDao;
import edu.tongji.jiaowu.service.EvtStudentManager;
import com.tongji.quickCRUDQ.model.CommonBean;

public class EvtStudentManagerImpl extends BaseManagerImpl implements EvtStudentManager {
	private EvtStudentDao evtStudentDao;
	private EvtStudentResultDao evtStudentResultDao;

	public CommonBean createEvtStudent() {
		return evtStudentDao.createEvtStudent();
	}

	public CommonBean findEvtStudentById(String id) {
		return evtStudentDao.findEvtStudentById(id);
	}

	public CommonBean findAllEvtStudents() {
		return evtStudentDao.findAllEvtStudents();
	}

	public void insertEvtStudent(CommonBean evtStudentBean) {
		evtStudentDao.insertEvtStudent(evtStudentBean);
	}

	public void updateEvtStudent(CommonBean evtStudentBean) {
		evtStudentDao.updateEvtStudent(evtStudentBean);
	}

	public void init(String year, String semester) {
		evtStudentDao.init(year,semester);
	}
	
	public CommonBean findEvTeachers(String year, String semester, String sno) {
		return evtStudentDao.findEvTeachers(year,semester,sno);
	}
	public String findEvTeachersJson(String year, String semester, String sno) {
		CommonBean bean=findEvTeachers(year, semester, sno);
		int n1=bean.getSize();
		StringBuffer json=new StringBuffer("[");
		for (int i = 0; i < n1; i++) {
			String id=bean.getId(i);
			String courseName=bean.getPropertyAsString(i,"courseName");
			String teacherName=bean.getPropertyAsString(i, "teacherName");
			String isFinish=bean.getPropertyAsString(i,"isFinish");
			String state="";
			if ("Y".equals(isFinish)) {
				state="【已评】";
			} 
			json.append("['").append(id).append("','").append(courseName).append("/").append(teacherName)
			.append(state).append("','").append(isFinish).append("','").append(courseName).append("','")
			.append(teacherName).append("']");
			if(i<n1-1){
				json.append(",");
			}			
		}
		json.append("]");
		return json.toString();
	}
	
	public void statistic(String year, String semester) {
		evtStudentDao.statistic(year,semester);
	}
	
	public EvtStudentDao getEvtStudentDao() {
		return evtStudentDao;
	}

	public void setEvtStudentDao(EvtStudentDao evtStudentDao) {
		this.evtStudentDao = evtStudentDao;
	}

	public EvtStudentResultDao getEvtStudentResultDao() {
		return evtStudentResultDao;
	}

	public void setEvtStudentResultDao(EvtStudentResultDao evtStudentResultDao) {
		this.evtStudentResultDao = evtStudentResultDao;
	}






}
